package com.tengju.motivation.domain.model.performance;

import lombok.Getter;

import java.util.Arrays;

/**
 * @author: 大木
 * @date: 2021/12/1 9:50 下午
 */
@Getter
public enum ChunMiaoTargetEnum {

    PROFIT_TARGET(1, "profitTarget", "收益目标"),
    UPGRADE_TARGET(2, "upgradeTarget", "晋升目标"),
    DEALER_PULL_TARGET(3, "dealerPullTarget", "经销商招募目标"),
    SVIP_PULL_TARGET(4, "svipPullTarget", "黑钻招募目标"),
    VVIP_PULL_TARGET(5, "vvipPullTarget", "白金招募目标"),
    CROWD_DEALER_CUT_TARGET(6, "crowdDealerCntTarget", "社群经销商数目标")
    ;

    private Integer code;
    private String key;
    private String desc;

    ChunMiaoTargetEnum(Integer code, String key, String desc) {
        this.code = code;
        this.key = key;
        this.desc = desc;
    }

    public static ChunMiaoTargetEnum form(String key) {
        return Arrays.stream(ChunMiaoTargetEnum.values())
                .filter(k -> k.getKey().equals(key))
                .findFirst().orElse(null);
    }

    public static ChunMiaoTargetEnum form(Integer code) {
        return Arrays.stream(ChunMiaoTargetEnum.values())
                .filter(k -> k.getCode().equals(code))
                .findFirst().orElse(null);
    }
}
